package cn.com.sd.log.dao.impl;

import java.util.List;

import org.springframework.stereotype.Component;

import cn.com.sd.common.util.MyStringUtils;
import cn.com.sd.common.util.Page;
import cn.com.sd.log.dao.IServiceLogDAO;
import cn.com.sd.log.model.ServiceLog;
import cn.com.sd.system.dao.hibernate.BaseDAOHibernate;

@SuppressWarnings("unchecked")
@Component(value = "serviceLogDAO")
public class ServiceLogDAOHibernate extends BaseDAOHibernate<ServiceLog> implements IServiceLogDAO{
	
	@Override
	public List<ServiceLog> getServiceLogList(Page page) {
		List<ServiceLog> serviceLogs = createQuery("from ServiceLog").setFirstResult(page.getStartRow()).setMaxResults(page.getStartRow() + page.getPageSize()).list();
		return serviceLogs;
	}
	
	@Override
	public Integer getServiceLogCount() {
		String hql = "select count(serviceLog.id) from ServiceLog serviceLog";
		Long count = (Long) findUnique(hql);
		return MyStringUtils.translateLongToInteger(count);
	}
}
